package com.project.application.server.system.controller;

import com.project.application.framework.web.controller.BaseController;
import com.project.application.framework.web.domain.AjaxResult;
import com.project.application.server.system.service.CaptchaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;

/**
 * @author :levnli
 */
@RestController
@RequestMapping("/captcha")
@Api(tags = {"验证码"})
public class CaptchaController extends BaseController {

    @Autowired
    private CaptchaService service;

    @GetMapping
    @ApiOperation("获取验证码")
    public AjaxResult getCaptcha() {
        return toAjax(service.getCaptcha());
    }

    @GetMapping("/sms")
    @ApiOperation("获取短信验证码")
    public AjaxResult getSmsCaptcha(@NotBlank String phone) {
        return toAjax(service.getSmsCaptcha(phone));
    }
}
